package ${table.basePackage}.vo;

<#-- 自动收集需要导入的类型并分类 -->
<#assign javaImports = []>
<#assign thirdPartyImports = []>
<#assign projectImports = []>

<#list columns as c>
  <#if c.javaType?? && c.javaType != "String" && c.javaType?contains(".")>
    <#if c.javaType?starts_with("java.") || c.javaType?starts_with("javax.")>
      <#assign javaImports = javaImports + [c.javaType]>
    <#elseif c.javaType?starts_with("com.kexio.")>
      <#assign projectImports = projectImports + [c.javaType]>
    <#else>
      <#assign thirdPartyImports = thirdPartyImports + [c.javaType]>
    </#if>
  </#if>
</#list>

<#-- 添加必需的import -->
<#assign thirdPartyImports = thirdPartyImports + ["com.fasterxml.jackson.annotation.JsonFormat"]>

<#-- 去重并排序 -->
<#function uniqueSort list>
  <#assign result = []>
  <#list list?sort as item>
    <#if !result?seq_contains(item)>
      <#assign result = result + [item]>
    </#if>
  </#list>
  <#return result>
</#function>

<#assign javaImports = uniqueSort(javaImports)>
<#assign thirdPartyImports = uniqueSort(thirdPartyImports)>
<#assign projectImports = uniqueSort(projectImports)>

<#-- 按顺序输出import -->
<#list javaImports as importClass>
import ${importClass};
</#list>
<#if javaImports?size gt 0 && (thirdPartyImports?size gt 0 || projectImports?size gt 0)>

</#if>
<#list thirdPartyImports as importClass>
import ${importClass};
</#list>
<#if thirdPartyImports?size gt 0 && projectImports?size gt 0>

</#if>
<#list projectImports as importClass>
import ${importClass};
</#list>

<#-- 函数：提取简单类名 -->
<#function getSimpleClassName fullClassName>
  <#if fullClassName?? && fullClassName?contains(".")>
    <#return fullClassName?split(".")?last>
  <#else>
    <#return fullClassName!"String">
  </#if>
</#function>

/**
 * ${table.comment!table.entityName} - 视图对象
 * 
 * 遵循Kexio开发规范：
 * - 用于接口返回，展示业务数据（排除敏感的租户ID、删除标记等）
 * - 包含审计字段（创建时间、更新时间）用于前端显示
 * - 支持字典翻译，提供友好的文本展示
 * - 不使用Lombok，手写getter/setter，提升调试友好性
 * 
 * 对应数据表：${table.tableName!''}
 * 
 * @author ${user.name!"系统"}
 * @since ${now?string('yyyy-MM-dd HH:mm:ss')}
 */
public class ${table.entityName}VO {

<#list columns as c>
  <#-- 跳过敏感字段，但保留审计字段用于前端显示 -->
  <#assign skipField = false>
  <#if c.columnName?? && (c.columnName?lower_case == "tenant_id" || c.columnName?lower_case == "deleted" || c.columnName?lower_case == "create_by" || c.columnName?lower_case == "update_by")>
    <#assign skipField = true>
  </#if>
  
  <#if !skipField>
    <#-- 时间字段添加格式化注解 -->
    <#if c.javaType?contains("LocalDateTime") || c.javaType?contains("LocalDate")>
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    </#if>
    /**
     * ${c.comment!(c.propertyName!'field')}
     */
    private ${getSimpleClassName(c.javaType)} <#if c.propertyName??>${c.propertyName}<#else>field</#if>;
    
    <#-- 如果有字典码，添加对应的文本字段 -->
    <#if c.dictCode?has_content>
    /**
     * ${c.comment!(c.propertyName!'field')} - 字典文本
     */
    private String <#if c.propertyName??>${c.propertyName}<#else>field</#if>Text;
    
    </#if>
  </#if>
</#list>

<#-- getters/setters -->
<#list columns as c>
  <#-- 跳过敏感字段，但保留审计字段用于前端显示 -->
  <#assign skipField = false>
  <#if c.columnName?? && (c.columnName?lower_case == "tenant_id" || c.columnName?lower_case == "deleted" || c.columnName?lower_case == "create_by" || c.columnName?lower_case == "update_by")>
    <#assign skipField = true>
  </#if>
  
  <#if !skipField>
    
    /**
     * 获取${c.comment!(c.propertyName!'field')}
     *
     * @return ${c.comment!(c.propertyName!'field')}
     */
    public ${getSimpleClassName(c.javaType)} get<#if c.propertyName??>${c.propertyName?cap_first}<#else>Field</#if>() { 
        return this.<#if c.propertyName??>${c.propertyName}<#else>field</#if>; 
    }

    /**
     * 设置${c.comment!(c.propertyName!'field')}
     *
     * @param <#if c.propertyName??>${c.propertyName}<#else>field</#if> ${c.comment!(c.propertyName!'field')}
     */
    public void set<#if c.propertyName??>${c.propertyName?cap_first}<#else>Field</#if>(${getSimpleClassName(c.javaType)} <#if c.propertyName??>${c.propertyName}<#else>field</#if>) { 
        this.<#if c.propertyName??>${c.propertyName}<#else>field</#if> = <#if c.propertyName??>${c.propertyName}<#else>field</#if>; 
    }
    
    <#-- 字典文本字段的getter/setter -->
    <#if c.dictCode?has_content>
    /**
     * 获取${c.comment!(c.propertyName!'field')}文本
     *
     * @return ${c.comment!(c.propertyName!'field')}文本
     */
    public String get<#if c.propertyName??>${c.propertyName?cap_first}<#else>Field</#if>Text() { 
        return this.<#if c.propertyName??>${c.propertyName}<#else>field</#if>Text; 
    }

    /**
     * 设置${c.comment!(c.propertyName!'field')}文本
     *
     * @param <#if c.propertyName??>${c.propertyName}<#else>field</#if>Text ${c.comment!(c.propertyName!'field')}文本
     */
    public void set<#if c.propertyName??>${c.propertyName?cap_first}<#else>Field</#if>Text(String <#if c.propertyName??>${c.propertyName}<#else>field</#if>Text) { 
        this.<#if c.propertyName??>${c.propertyName}<#else>field</#if>Text = <#if c.propertyName??>${c.propertyName}<#else>field</#if>Text; 
    }
    
    </#if>
  </#if>
</#list>
}



